home *** CD-ROM | disk | FTP | other *** search
- Path: tech.cftnet.com!usenet
- From: ams@cftnet.com
- Newsgroups: comp.lang.c++
- Subject: Re: problem initializing static member of a class.
- Date: Tue, 06 Feb 1996 21:11:36 GMT
- Organization: CFTnet
- Message-ID: <4f8fq2$5ll@tech.cftnet.com>
- References: <4eumvq$ko1@uwm.edu>
- NNTP-Posting-Host: ppp245_10.cftnet.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- kumbera@allmalt.cs.uwm.edu (Mike Kumbera) wrote:
-
- >I'm having troubles getting a static initilaizer for a member
- > of a class working. I want to declare a static array of pointers
- > to a class as a member of the class.
- >(If this is possible)
-
- >The following code is a short example of what I'm trying to do:
-
-
- >------------------------------------------------------------
-
- >#include <iostream.h>
- >
- >class TEST
- >{
- > // a static array of pointers to the class TEST
- > static TEST *TEST_ptr[];
- >};
- >
- >// initialize the static member (I can't get this working)
- >TEST *TEST::TEST_ptr[] = NULL;
- >
- >main()
- >{
- > TEST a;
- >}
-
-
- >------------------------------------------------------------
-
- >When I compile the code with gcc I get:
- >help.C:10: invalid initializer
-
- >ANY ideas would be appreciated...
-
- >mkumbera@cs.uwm.edu (Michael Kumbera)
-
-
-
- Try this...
-
- class TEST
- {
- // a static array of pointers to the class TEST
- static TEST *TEST_ptr;
- };
-
- // initialize the static member (I can't get this working)
- TEST *TEST::TEST_ptr = NULL;
-
- main()
- {
- TEST a;
- }
-
-
-
-